/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.clebersantos;

import com.clebersantos.controller.PrincipalController;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

/**
 *
 * @author Jurema
 */
public class LoginStart extends Application {
    
    public static boolean isLogado = false;
    public static String nome;
    public static Stage myStage;
    public static Stage myStage2;
    
    @Override
    public void start(Stage stage) throws Exception {
        if(!isLogado){
            
            Parent root = FXMLLoader.load(getClass().getResource("view/FXMLLogin.fxml"));
            
            LoginStart.myStage = stage;
        
            Scene scene = new Scene(root);

            myStage.setScene(scene);
            myStage.show();
            
        }else{
            
            Parent root = FXMLLoader.load(getClass().getResource("view/Principal.fxml"));
            
            LoginStart.myStage2 = stage;
        
            Scene scene = new Scene(root);

            myStage2.setScene(scene);
            PrincipalController.bemVindo.setText("Seja bem-vindo(a), " + nome.toUpperCase() + "!");
            myStage2.show();
            LoginStart.myStage.close();
            
        }
    }

    /**
     * The main() method is ignored in correctly deployed JavaFX application.
     * main() serves only as fallback in case the application can not be
     * launched through deployment artifacts, e.g., in IDEs with limited FX
     * support. NetBeans ignores main().
     *
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
    
}
